﻿using Fluent.IO;
using Sidewinder.Core.Interfaces.Entities;
using FluentAssertions;
using Wolfpack.Core;

namespace Wolfpack.Contrib.Tests.Publishers.Deployment
{
    using Contrib.Deployment;

    public class DeploymentPublisherDomain : DeploymentPublisherDomainBase<DeploymentConfig>
    {
        private DeploymentConfig _actualConfig;

        public DeploymentPublisherDomain()
        {
            SetDeploymentBaseConfig(new DeploymentConfig());
            TheConfigFolderIsCleaned();
        }

        private void TheConfigFolderIsCleaned()
        {
            Path.Get("Config").Delete(true);
        }

        public void TheComponentConfig_IsUsed(string configFile)
        {
            Path.Get(@"TestData\Config", configFile).Copy(@"Config\" + configFile, Overwrite.Always);
        }

        public void TheDeploymentComponent_IsResolved(string componentName)
        {
            SafeExecute(() => _actualConfig = (DeploymentConfig)Container.Resolve(componentName));
        }


        public void TheConflictResolutionPropertyShouldBe_(ConflictResolutionTypes expected)
        {
            _actualConfig.ConflictResolution.Should().Be(expected);
        }

        public void ThePublisherIsCalled()
        {
            var sut = new DeploymentPublisher(_config)
            {
                Updater = _updater
            };

            sut.Consume(_triggerNotification);
        }
    }
}